package com.summer.filter;

import com.summer.util.Constant;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 作者:夏天
 * qq:1205232048
 */
public class sysFilter implements Filter {
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) servletRequest;
        HttpServletResponse resp = (HttpServletResponse) servletResponse;

        if(req.getSession().getAttribute(Constant.USER_SESSION) == null){
            resp.sendRedirect("/fail.jsp");
        }
        filterChain.doFilter(req,resp);
    }

    public void destroy() {

    }
}
